package com.ly.consumer.thread.threadCommonMethod;


class MyPriorityThread implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 50; i++) {
            System.out.println(Thread.currentThread().getName() + "====" + i);
        }
    }
}


//线程的常用方法
public class MyPriorityDemo {
    //设置线程优先级
    public static void main(String[] args) {
        MyPriorityThread myPriorityThread = new MyPriorityThread();
        Thread t1 = new Thread(myPriorityThread);
        t1.setName("线程1");
        t1.setPriority(Thread.MAX_PRIORITY);
        Thread t2 = new Thread(myPriorityThread);
        t2.setName("线程2");
        Thread t3 = new Thread(myPriorityThread);
        t3.setName("线程3");
        t3.setPriority(Thread.MIN_PRIORITY);
        t1.start();
        t2.start();
        t3.start();
    }
}
